package com.chance.cc.crawler.development.bootstrap.autohome.article;

import com.chance.cc.crawler.core.CrawlerEnum;
import com.chance.cc.crawler.core.downloader.HttpConfig;
import com.chance.cc.crawler.core.downloader.proxy.Proxy;
import com.chance.cc.crawler.core.filter.FilterUtils;
import com.chance.cc.crawler.core.record.CrawlerRequestRecord;
import com.chance.cc.crawler.development.controller.DevCrawlerController;

/**
 * @author lt
 * @version 1.0
 * @date 2020-11-19 18:11:33
 * @email okprog@sina.com
 */
public class ArticleStart {

    private static final String domain = "autohome_article";

    public static void main(String[] args) {

        Proxy proxy = new Proxy();
        proxy.setHost("http-dyn.abuyun.com");
        proxy.setPort(9020);
        proxy.setUsername("HEW657EL99F83S9D");
        proxy.setPassword("8916B1F3F10B1979");

        CrawlerRequestRecord requestRecord = CrawlerRequestRecord.builder()
                .startPageRequest(domain,CrawlerEnum.CrawlerRequestType.turnPage)
                .domain(domain)
                .recordKey("https://www.autohome.com.cn/all/")
                .httpUrl("https://www.autohome.com.cn/all/")
                .releaseTime(System.currentTimeMillis())
                .httpConfig(HttpConfig.me(domain))
                .filter(CrawlerEnum.CrawlerRecordFilter.keyOrDateRange)
                .addFilterInfo(FilterUtils.memoryFilterKeyInfo(domain))
                .addFilterInfo(FilterUtils.dateRangeFilterInfo(24*1,null))
//                .proxy(proxy)
                .build();


        DevCrawlerController.builder()
                .triggerInfo(domain,domain + "_forum_article_trigger",System.currentTimeMillis(),domain+ "_forum_article_job")
                .crawlerRequestQueue(DevCrawlerController.devRequestQueue(domain)) //内存队列
                .consoleResultPipeline() //控制台输t出
//                .fileResultPipeline("D:\\chance\\log\\tets.log",true)
                .requestRecord(requestRecord)
                .build()
                .start();
    }
}
